<?php 
namespace app\common\model;
use think\facade\Cache;
use think\Model;
class CompanyIndustry extends Model
{
    public static function getSelect($where=[])
    {
        $Data=self::where($where)->order('sort asc,id asc')->select();
        foreach ($Data as $k => $v) {
            $Data[$k]['hasChildren']=self::where(['pid'=>$v['id']])->count();
        }
        return $Data;
    }
	public static function getCate()
	{
		$CompanyIndustry=Cache::get('CompanyIndustry');
//        dd($CompanyIndustry);
		if($CompanyIndustry)
			return $CompanyIndustry;
		return self::getCache();
	}
	public static function getCache()
	{
	    $cate=self::where(['pid'=>0,'status'=>1])->order('sort asc')->column('title,id','id');
	    foreach ($cate as $k => $v) {
	        $cate[$k]['data']=self::where(['pid'=>$v['id'],'status'=>1])->order('sort asc')->column('title,id','id');
	    }
		return $cate;
	}
}